﻿@using Newtouch.Common.Operator;
@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}

<form id="form1">
    <div style="padding: 20px 35px 0 2px;">
        <table class="form">
            <tr>
                <th class="formTitle">首字母：</th>
                <td class="formValue">
                    <input name="szm" type="text" class="form-control" id="szm" />
                </td>
            </tr>
            <tr>
                <th class="formTitle"><span class="required">*</span>起始收据号：</th>
                <td class="formValue">
                    <input type="text" class="form-control" id="qssjh" name="qssjh" required />
                </td>
                <th class="formTitle"><span class="required">*</span>结束收据号：</th>
                <td class="formValue">
                    <input type="text" class="form-control" id="jssjh" name="jssjh" required />
                </td>
            </tr>
            <tr>
                <th class="formTitle"><span class="required">*</span>当前单据号：</th>
                <td class="formValue">
                    <input type="text" class="form-control" id="dqsjh" name="dqsjh" required />
                </td>
                <th class="formTitle">有效</th>
                <td class="formValue">
                    <div class="ckbox">
                        <input id="zt" type="checkbox" checked="checked"><label for="zt"></label>
                    </div>
                </td>
            </tr>
            <tr>
                <th class="formTitle"><span class="required">*</span>领用人员：</th>
                <td class="formValue">
                    <input type="text" class="form-control" id="ry" name="ry" required />
                </td>
                <th class="formTitle">领用日期：</th>
                <td class="formValue">
                    <input id="CreateTime" type="text" class="form-control input-wdatepicker" value="@DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss' })" />
                </td>
            </tr>
        </table>
    </div>
</form>

<script>
    var Id = $.request("Id");
    $(function () {
        initControl();
        if (!!Id) {
            $.ajax({
                url: "/SystemManage/FinancialReceipt/GetFormJson?r=" + Math.random(),
                data: { Id: Id },
                dataType: "json",
                async: false,
                success: function (data) {
                    $("#form1").formSerialize(data);
                    //格式化UTC日期
                    $("#CreateTime").val(new Date(data.CreateTime).format("yyyy-MM-dd hh:mm:ss"));
                    $("#CreateTime").val(new Date(data.CreateTime).format("yyyy-MM-dd hh:mm:ss"));
                }
            });
        }
    })
    function initControl() {

    }

    function submitForm() {
        if (!$('#form1').formValid()) {
            return false;
        }
        var params = $("#form1").formSerialize();
        $.submitForm({
            url: "/SystemManage/FinancialReceipt/SubmitForm?Id=" + Id,
            param: params,
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }

    //领用人员
    $("#ry").click(function () {
        $.modalOpen({
            id: "FormSysFPPZUsers",
            title: "选择操作员",
            url: "/SystemManage/SysUser/Selector?isContansChildOrg=false&organizeId=" + '@(Newtouch.Common.Operator.OperatorProvider.GetCurrent().OrganizeId)' + "&isExpand=true&callbackType=json&single=true&fromDialog=FormFIEdit",
            width: "650px",
            height: "570px",
            callBack: function (iframeId) {
                top.frames[iframeId].AcceptClick(function (data) {
                    userStaffTreeCallback(data);
                });
            }
        });
    });
    //用户人员树回调方法
    function userStaffTreeCallback(data) {
        $("#ry").val(data[0].Code);
    }

</script>
